package com.dragon.repository.domain.vo;

import com.dragon.common.model.Update;
import com.dragon.repository.entity.Goods;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import com.dragon.common.util.BeanUtils;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Date;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class GoodsVO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "客户id")
    private Integer customerId;

    @ApiModelProperty(value = "产品名称")
    private String goodsName;

    @ApiModelProperty(value = "产品编码")
    private String goodsNum;

    @ApiModelProperty(value = "产品价格")
    private BigDecimal price;

    @ApiModelProperty(value = "产品描述(备注)")
    private String remark;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date updateTime;

    @ApiModelProperty(value = "用户id")
    private Integer adminId;

    @ApiModelProperty(value = "部门id")
    private Integer departmentId;



 @ApiModelProperty(value = "删除标识：0未删除 1已删除")
    private Integer deleted;
    @NotNull(groups = Update.class,message = "主键不能为空")
    public static Goods convert(GoodsVO vo) {
        Goods entity = new Goods();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<Goods> convertList(List<GoodsVO> list) {
        List<Goods> resultList = new ArrayList<>();
        for (GoodsVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
